<?php
function convertSpace($string) {
	return str_replace ( "_", " ", $string );
}

$string = "Peter_is_a_great_guy!";

echo filter_var ( $string, FILTER_CALLBACK, array (
		"options" => "convertSpace" 
) );
?>